package net.cloudcodex.client.character.view.panel;

import net.cloudcodex.client.character.view.CharactersView.Message;

import com.google.gwt.event.logical.shared.HasValueChangeHandlers;
import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.TextBox;

public class CharacterAdvancedInfosPanel extends FlowPanel {

	private final Label lblName = new Label();
	private final TextBox nametxtbx = new TextBox();
	private final Label lblIcon = new Label();
	private final TextBox icontxtbx = new TextBox();
	private final CheckBox profileChkBx = new CheckBox();
	private final CheckBox lockedChkBx = new CheckBox();
	private final CheckBox deadChkBx = new CheckBox();
	private Message message;
	private final HorizontalPanel profilePanel = new HorizontalPanel();
	private final HorizontalPanel statePanel = new HorizontalPanel();

	public CharacterAdvancedInfosPanel() {

	}

	public void initComponents() {

		final HorizontalPanel namePanel = new HorizontalPanel();
		lblName.setText(message.getCharacterNameLbl());
		namePanel.add(lblName);
		namePanel.add(nametxtbx);
		nametxtbx.setTitle("nameTxtBx");
		final HorizontalPanel iconPanel = new HorizontalPanel();
		lblIcon.setText(message.getCharacterIconLabel());
		iconPanel.add(lblIcon);
		iconPanel.add(icontxtbx);
		icontxtbx.setTitle("iconTxtBx");
		profileChkBx.setText(message.getCharacterProfileLabel());
		profileChkBx.setTitle("profileChkBx");
		lockedChkBx.setText(message.getCharacterLockedLabel());
		lockedChkBx.setTitle("lockedChkBx");
		deadChkBx.setText(message.getCharacterDeadLabel());
		deadChkBx.setTitle("deadChkBx");
		this.add(namePanel);
		this.add(iconPanel);
		this.add(profilePanel);
		this.add(statePanel);
	}

	public void setName(String name) {
		this.nametxtbx.setText(name);
	}

	public void setIcon(String icon) {
		this.icontxtbx.setText(icon);
	}

	public void setProfile(boolean isProfile) {
		profileChkBx.setValue(isProfile);
	}

	public void setLocked(boolean isLocked) {
		lockedChkBx.setValue(isLocked);
	}

	public void setDead(boolean isdead) {
		deadChkBx.setValue(isdead);
	}

	public boolean isProfile() {
		return profileChkBx.getValue();
	}

	public boolean isLocked() {
		return lockedChkBx.getValue();
	}

	public boolean isDead() {
		return deadChkBx.getValue();
	}

	public void setMessage(Message message) {
		this.message = message;
	}

	public void isActive(boolean isActive) {
		if (!isActive) {
			profilePanel.add(profileChkBx);
			statePanel.clear();
		}
		if (isActive) {
			profilePanel.clear();
			statePanel.add(lockedChkBx);
			statePanel.add(deadChkBx);
		}
	}

	public TextBox getNameTextBox() {
		return nametxtbx;
	}

	public TextBox getIconTextBox() {
		return icontxtbx;
	}
	
	public HasValueChangeHandlers<Boolean> getProfileChkBx(){
		return profileChkBx ;
	}
	
	public HasValueChangeHandlers<Boolean> getLockedChkBx(){
		return lockedChkBx ;
	}

	public HasValueChangeHandlers<Boolean> getDeadChkBx(){
		return deadChkBx ;
	}

}
